<?php 
if (auth_errors() || validation_errors()){
	Template::set_message(auth_errors() . validation_errors(), 'error');
}
?>

<?php if (isset($user) && $user->role_name == 'Banned') : ?>
<div class="alert-message block-message error fade in" data-alert="alert">
	<a class="close" href="#">x</a>
	<p><?php echo lang('us_banned_admin_note'); ?></p>
</div>
<?php endif; ?>

<p><?php echo lang('bf_required_note'); ?></p>

<?php echo form_open($this->uri->uri_string()); ?>
<fieldset>
<div class="clearfix">
	<label for="first_name"><?php echo lang('us_first_name'); ?></label>
	<div class="input">
		<input type="text" name="first_name" value="<?php echo isset($user) ? $user->first_name : set_value('first_name') ?>" />
	</div>
</div>

<div class="clearfix">
	<label for="last_name"><?php echo lang('us_last_name'); ?></label>
	<div class="input">
		<input type="text" name="last_name" value="<?php echo isset($user) ? $user->last_name : set_value('last_name') ?>" />
	</div>
</div>

<div class="clearfix">
	<label class="required" for="email"><?php echo lang('bf_email'); ?></label>
	<div class="input">
		<input type="text" name="email" class="medium" value="<?php echo isset($user) ? $user->email : set_value('email') ?>" />
	</div>
</div>

<?php if ( config_item('auth.login_type') !== 'email' OR config_item('auth.use_usernames')) : ?>
<div class="clearfix">
	<label class="required" for="username"><?php echo lang('bf_username'); ?></label>
	<div class="input">
		<input type="text" name="username" id="username" class="medium" value="<?php echo isset($user) ? $user->username : set_value('username') ?>" />
	</div>
</div>
<?php endif; ?>

<div class="clearfix">
	<label class="required" for="password"><?php echo lang('bf_password'); ?></label>
	<div class="input">
		<input type="password" id="password" name="password" value="" />
	</div>
</div>
<div class="clearfix">
	<label class="required" for="pass_confirm"><?php echo lang('bf_password_confirm'); ?></label>
	<div class="input">
		<input type="password" id="pass_confirm" name="pass_confirm" value="" />
	</div>
</div>
</fieldset>

<?php  if ( ! config_item('auth.use_extended_profile')) :?>
<fieldset>
<legend><?php echo lang('us_address'); ?></legend>

<div class="clearfix">
	<label for="street_1"><?php echo lang('us_street_1'); ?></label>
	<div class="input">
		<input type="text" name="street_1" class="medium" value="<?php echo isset($user) ? $user->street_1 : set_value('street_1') ?>" />
	</div>
</div>
<div class="clearfix">
	<label for="street_2"><?php echo lang('us_street_2'); ?></label>
	<div class="input">
		<input type="text" name="street_2" class="medium" value="<?php echo isset($user) ? $user->street_2 : set_value('street_2') ?>" />
	</div>
</div>
<div class="clearfix">
	<label for="city"><?php echo lang('us_city'); ?></label>
	<div class="input">
		<input type="text" name="city" value="<?php echo isset($user) ? $user->city : set_value('city') ?>" />
	</div>
</div>
<div class="clearfix">
	<label for="iso"><?php echo lang('us_country') ?></label>
	<div class="input">
		<?php echo country_select(isset($user) && !empty($user->country_iso) ? $user->country_iso : 'US', 'US'); ?>
	</div>
</div>
<div class="clearfix">
	<label for="state_code"><?php echo lang('us_state'); ?></label>
	<div class="input">
		<?php echo state_select(isset($user) ? $user->state_code : '', 'MO', isset($user) && !empty($user->country_iso) ? $user->country_iso : 'US'); ?>
	</div>
</div>
<div class="clearfix">
	<label for="zipcode"><?php echo lang('us_zipcode'); ?></label>
	<div class="input">
		<input type="text" name="zipcode" size="7" maxlength="7" style="width: 6em; display: inline;" value="<?php echo isset($user) ? $user->zipcode : set_value('zipcode', ' ') ?>"  /> 
	</div>
</div>

</fieldset>
<?php endif; ?>

<div class="actions">
	<input type="submit" name="submit" class="btn primary" value="<?php echo lang('bf_action_save') ?> " />
	<?php if (isset($user) && has_permission('Site.User.Manage')) : ?>
	<a class="btn danger" id="delete-me" href="<?php echo site_url(SITE_AREA .'/settings/users/delete/'. $user->id); ?>" onclick="return confirm('<?php echo lang('us_delete_account_confirm'); ?>')"><?php echo lang('us_delete_account'); ?></a>
	<?php endif; ?>
</div>

<?php echo form_close(); ?>